﻿@model DHQGHN.PM2.Models.DonViModel

@*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")*@
@{
    var lstNhomDonVi = ViewBag.lstNhomDonVi;
    //var lstNhomDonViKhac = ViewBag.lstNhomDonViKhac;
}

@using (Html.BeginForm("ActionSaveDonVi", "DonVi", FormMethod.Post, new { @id = "frmCapNhatNhomDonVi" }))
{
    <div class="row">
        <div class="col-md-12">
            <fieldset id="fs1" class="fs_group1" style="border-style:hidden;">
                @Html.HiddenFor(m => m.DonViId)
                <div class="row" style="margin-top: 5px;">
                    <div class="col-md-4" style="">
                        @Html.Label("Nhóm đơn vị cơ bản:")
                        <font size="3" color="red" style="display:inline;" class="pm2-hidden">*</font>
                    </div>
                    <div class="col-md-8" style="">
                        @Html.DropDownList("NhomDonViId", lstNhomDonVi as List<SelectListItem>, null, new { @class = "form-control input-sm" })
                        <span style="color: red;">
                            @Html.ValidationMessageFor(m => m.NhomDonViId)
                        </span>
                    </div>
                </div>
                <div class="row" style="margin-top: 5px;">
                    <div class="editor-label col-md-4">
                        <label for="categories">Nhóm đơn vị khác:</label>
                    </div>
                </div>
                <div class="row" style="margin-top: 5px;">
                    <div class="editor-field">
                        @*@for (var i = 0; i < Model.listNhomDonVi.Count; i++)
                            {
                                <label class="col-md-4">
                                    @{
                                        @Html.HiddenFor(it => it.listNhomDonVi[i].NhomDonViId)
                                        @Html.DisplayFor(it => it.listNhomDonVi[i].TenNhomDonVi)
                                        bool boolChecked = false;
                                        if (Model.listNhomDonVi[i].IS_CHECKED == 1) { boolChecked = true; }
                                        @Html.CheckBox("listNhomDonVi", boolChecked);
                                    }
                                </label>
                            }*@
                        @for (int i = 0; i < Model.listNhomDonVi.Count; i++)
                        {
                            <label class="col-md-4">
                                @{
                                    if (Model.listNhomDonVi[i].IS_CHECKED == 1)
                                    {
                                        <input type="checkbox" name="listNhomDonVi" value="@Model.listNhomDonVi[i].NhomDonViId"
                                               checked='checked'>@Model.listNhomDonVi[i].TenNhomDonVi
                                    }
                                    else if (Model.listNhomDonVi[i].IS_CHECKED == 0)
                                    {
                                        <input type="checkbox" name="listNhomDonVi" value="@Model.listNhomDonVi[i].NhomDonViId">@Model.listNhomDonVi[i].TenNhomDonVi
                                    }
                                }
                            </label>
                        }
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
}

@Scripts.Render("~/bundles/jqueryval")

<script>
    @functions{
            public string GetAntiForgeryToken()
            {
                string cookieToken, formToken;
                AntiForgery.GetTokens(null, out cookieToken, out formToken);
                return cookieToken + "," + formToken;
            }
        }
</script>
<script>

    @*var $form = $("#certification-form");
    function save() {
        var result = false;
        if ($form.valid()) {
            $.ajax({
                type: "POST",
                url: $form.attr('action'),
                data: $form.serialize(),
                dataType: '',//chú ý là form đặc biệt thì phải điền trường này
                async: false,
                headers: {
                    'VerificationToken': '@GetAntiForgeryToken()'
                },
                success: function (response) {
                    if (response != null && response.status == 200) {
                        window.notice(response.result, window.notice_success);
                        OnCriteria(0);
                        result = true;
                    } else {
                        window.notice(response.result, window.notice_error);
                    }
                }
            });
        }
        return result;
    }*@
</script>